package zdream.pmfield.core;

import java.io.Serializable;
import java.util.Objects;

/**
 * @author Zdream
 * @date 2023-11-30
 * @since 0.0.1
 */
public class Result implements Serializable {
	public final boolean success;
	public final String errorMessage;

	public boolean isSuccess() {
		return success;
	}

	private Result() {
		this.success = true;
		this.errorMessage = null;
	}

	private Result(String errorMessage) {
		this.success = false;
		this.errorMessage = Objects.requireNonNull(errorMessage);
	}

	public static Result ofSuccess() {
		return new Result();
	}

	public static Result ofFailure(String errorMessage) {
		return new Result(errorMessage);
	}
}
